﻿<%@ Control Language="C#" AutoEventWireup="false" CodeFile="USIXExportList.ascx.cs" Inherits="Controls_USIX_USIXExportList" %>
<%@ Register Src="~/Controls/Collection/Payments.ascx" TagName="PaymentsMB" TagPrefix="UI"  %>
<style>
cool\:tip{behavior: url(/Include/HTC/cooltip_js.htc)}
TABLE.GridView.Bridge TH INPUT.Filter{	text-transform:uppercase;	behavior1: url(/Include/HTC/TipMe.htc)}
CAPTION {BEHAVIOR: url(/Include/HTC/Toggle.htc);COLOR:navy;FONT-WEIGHT:bold}
TABLE.GridView TD.BorderRight{	border-right-width:1px;	border-right-color: Black}
TABLE.GridView TD.NextDue{background-color:#F5F5F5}
TABLE.GridView TD.Red{background-color:#FFE5E5}
TABLE.GridView TD.RedDark{color:#B80000}
TABLE.GridView TD.GreenDark{color:#006600}
TABLE.GridView TD.U A{color:black;text-decoration:none}
TABLE.GridView TD.U A.Bold{font-weight:bold}
TABLE.GridView TR TD,TH {font-size:<%=ddlFontSize.SelectedValue%>}
TABLE.Big TD,TH {font-size:<%=ddlFontSize.SelectedValue%>}
.Big{font-size:<%=ddlFontSize.SelectedValue%>}
.button INPUT {overflow:visible;padding:0px 3px;vertical-align:middle}
.button SELECT {vertical-align:middle}
SPAN.CheckBox INPUT{border:none;vertical-align:middle}
</style>
<asp:UpdatePanel ID="upButtons" UpdateMode="Always" runat="server">
<Triggers>
	<asp:PostBackTrigger ControlID="btnExcel" />
	<asp:PostBackTrigger ControlID="ShowWelcomeLetters" />
	<asp:PostBackTrigger ControlID="ddlFontSize" />
</Triggers><ContentTemplate>
<asp:ObjectDataSource ID="dsUsersCached" SelectMethod="GetUsers" runat="server" />
<span class="button">
<asp:DropDownList id="ddlUsers" DataSourceID="dsUsersCached" DataTextField="Nick" DataValueField="UserName" runat="server" AutoPostBack="true" AppendDataBoundItems="true"
		 OnDataBound="ddlUsers_DataBound" OnSelectedIndexChanged="ddlUsers_SelectedIndexChanged"
>
<asp:ListItem Text ="Self" Value=""></asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnSaveFilter" OnClientClick="if(!saveFilter())return false;" CommandName="SaveFilter" runat="server" Text="Save Filter" />
<asp:DropDownList ID="ddlFilters" DataSourceID="dsFilters" DataTextField="Name" DataValueField="Value" AutoPostBack="true" runat="server"
		 OnPreRender="ddlFilters_PreRender" OnSelectedIndexChanged="ddlFilters_SelectedIndexChanged"
></asp:DropDownList>
<asp:Button ID="btnDeleteFilter" CommandName="DeleteFilter" runat="server" Text="Delete Filter" />
<asp:ImageButton ID="btnExcel" ImageUrl="/Manager/Menu/Images/Excel.gif" CommandName="Excel"  runat="server" />
<input type="button" value="Tasks" onclick="openTasks()" style="vertical-align:middle" />
<asp:CheckBox ID="chkFieldChooser" Checked="false" runat="server" Text="Field Chooser" AutoPostBack="true" CssClass="CheckBox" />
<asp:DropDownList ID="ddlLetters" runat="server">
<asp:ListItem Text="Select ..." Value="" />
<asp:ListItem Value="Welcome" Text="Welcome" />
<asp:ListItem Value="Delinquency.PastDue_02_06" Text="Past Due(2-6)" />
<asp:ListItem Value="Delinquency.PastDue_15_20" Text="1st Letter(15-20)" />
<asp:ListItem Value="Delinquency.PastDue_25_29" Text="2st Letter(25-29)" />
<asp:ListItem Value="Delinquency.PastDue_31_35" Text="Serious Letter(31-35)" />
<asp:ListItem Value="Delinquency.PastDue_36" Text="Final Letter(36)" />
<asp:ListItem Value="Delinquency.NSF" Text="N.S.F." />
<asp:ListItem Value="Delinquency.BrokenPromise" Text="Broken Promise" />
<asp:ListItem Value="ReStart" Text="Re-Start" />
<asp:ListItem Value="ReStart_A" Text="Re-Start(Apr)" />
<asp:ListItem Value="Invoice" Text="Invoice" />
</asp:DropDownList>
<asp:LinkButton OnClientClick="document.all.tags('FORM')[0].target='_blank';" ToolTip="Click to generate Letters for selected list" text="Show Letters" CommandName="Letter" runat="server" ID="ShowWelcomeLetters" />
</span>
</ContentTemplate></asp:UpdatePanel>
<hr style="border-style:outset">
<div id="divGrid"><!-- Bridge -->
<asp:UpdatePanel ID="upBridge" UpdateMode="Always" runat="server"><ContentTemplate>
<span title="Change Font Size">
<asp:DropDownList ID="ddlFontSize" style="background-color:#D1FFDC;vertical-align:middle" AutoPostBack="true" runat="server">
<asp:ListItem Text="100%" Value="100%" />
<asp:ListItem Text="120%" Value="120%" Selected="True" />
<asp:ListItem Text="140%" Value="140%" />
<asp:ListItem Text="160%" Value="160%" />
</asp:DropDownList></span><asp:Label style="font-size:85%" id="lblCaption" runat="server"></asp:Label>
<DS:USIXExportDataSource ID="ds"
		SelectList="*,CASE WHEN LoanID > 0 THEN 0 ELSE 1 END NeedImport,'*'+RIGHT(SSN,4)SSN4,'*'+RIGHT(VIN,6)VIN6,CONVERT(bit,CASE WHEN [Status Code] IN ('O','L') AND DPD > 0 THEN 1 ELSE 0 END) ShowDPD" FilterDefault="1=0" runat="server" />
<UI:GridViewMB ID="grv" runat="server" AutoGenerateColumns="false" DataSourceID="ds"
	ShowFooter="false" AllowSorting="True" CellPadding="0" PageSize="25"
	AllowEdit="false" ShowDelete="false" RowStyle-HorizontalAlign="Right"
	RowStyle-Font-Size="XX-Small"
	Caption="" CaptionAlign="Left" CssClass="Bridge"
	EnableViewState="true" DataKeyNames="UsixID,CompanyID_Raw,ApplID">
	<Columns>
<asp:TemplateField HeaderText="ApplID" SortExpression="ApplID">
<ItemTemplate>
	<span style="cursor:hand;font-weight:bold;color:Navy" title='Click to open <%#Eval("ApplID")%>'
		onclick='<%#ShowApplicantJS(Eval("ApplID"))%>'><%#Eval("ApplID")%>
	</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="UsixID" SortExpression="UsixID">
	<ItemTemplate>
		<span title='<%#Eval("Open Field#01")+""==""||Eval("NeedImport")+""=="1"?"[Open Field#01] : "+Eval("Open Field#01"):"Click to open by [Open Field#01] : "+Eval("Open Field#01")%>'
					Style='font-weight:<%#Eval("NeedImport")+""=="0"?"bold":""%>;
								 color:<%#Eval("NeedImport")+""=="1"?"DimGray":""%>
								 '
					onclick='<%#Eval("Open Field#01")+""==""||Eval("NeedImport")+""=="1"?"":ShowApplicantJS(Eval("Open Field#01"))%>'
		><%#Eval("UsixID")%></span>
	</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="<span title='1-AFC,2-DA,3-Heller4,4-AFQ,5-SF'>U</span>" SortExpression="CompanyID" ItemStyle-CssClass="U">
	<ItemTemplate>
		<asp:LinkButton Visible='<%#Eval("NeedImport")+""=="1"%>' CssClass='<%#Eval("NeedImport")+""=="1"?"Bold":""%>' ID="btnImport" Text='<%#Eval("CompanyID")%>'
				OnClientClick='event.cancelBubble=true;return confirm("Import from USIX?")'
				 title='<%#Eval("NeedImport")+""=="0"?"":"Click to Import [Open Field #1] : "+Eval("Open Field#01")+" from Usix"%>'
				 CommandName="Import" CommandArgument='<%#Eval("UsixID")+","+Eval("CompanyID")%>' OnCommand="USIXExportList_Command" runat="server" />
		<%#Eval("NeedImport")+""=="1"?"":Eval("CompanyID")%>
	</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SSN" SortExpression="SSN">
	<ItemTemplate><span title='<%#Eval("SSN")+" : " + Eval("Name")%>'><%#Eval("SSN")%></span></ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="VIN" HeaderText="VIN" SortExpression="VIN" />
<!-- #include virtual="../Collection/MainColumns.asp" -->
	<asp:BoundField DataField="NSF_DaysSince" HeaderText="<span title='NSF Days Since'>NDS</span>" HtmlEncode="false" SortExpression="NSF_DaysSince"></asp:BoundField>
	<asp:BoundField DataField="Car Year" HeaderText="<span title='Car Year'>CY</span>" DataFormatString="{0:#}"  HtmlEncode="false" SortExpression="Car Year"></asp:BoundField>
	<asp:BoundField DataField="A_R Balance" HeaderText="A_R Balance" DataFormatString="{0:c0}"  HtmlEncode="false" SortExpression="A_R Balance"></asp:BoundField>
	<asp:BoundField DataField="RemBalance78" HeaderText="Rem Balance 78" DataFormatString="{0:c0}"  HtmlEncode="false" SortExpression="RemBalance78"></asp:BoundField>
	<asp:BoundField DataField="DefermentsCount" HeaderText="<span title='Deferments Count'>Df#</span>" DataFormatString="{0:n0}"  HtmlEncode="false" SortExpression="DefermentsCount"></asp:BoundField>
	<asp:BoundField DataField="Last Payment Date" ItemStyle-CssClass="NextDue" DataFormatString="{0:MM/dd/yy}" HtmlEncode="false" HeaderText="<span title='Last Payment Date'>Last Pmt</span>" SortExpression="Last Payment Date"></asp:BoundField>
	<asp:BoundField DataField="Status_Repo" HeaderText="Repo Status" SortExpression="Status_Repo"></asp:BoundField>
	<asp:BoundField DataField="StatusDate_Repo" HeaderText="Repo Status Date" SortExpression="StatusDate_Repo" DataFormatString="{0:MM/dd/yy}"></asp:BoundField>
	<asp:BoundField DataField="StatusUser_Repo" HeaderText="Repo Status User" SortExpression="StatusUser_Repo"></asp:BoundField>
	<asp:BoundField DataField="RepoAgent" HeaderText="Repo Agent" SortExpression="RepoAgent"></asp:BoundField>

	<asp:BoundField DataField="Status_BK" HeaderText="BK Status" SortExpression="Status_BK"></asp:BoundField>
	<asp:BoundField DataField="StatusDate_BK" HeaderText="BK Status Date" SortExpression="StatusDate_BK" DataFormatString="{0:MM/dd/yy}"></asp:BoundField>
	<asp:BoundField DataField="StatusUser_BK" HeaderText="BK Status User" SortExpression="StatusUser_BK"></asp:BoundField>

	<asp:BoundField DataField="StatusCodePrev" HeaderText="<span title='USIX Status Code Prev'>SCP</span>" HtmlEncode="false" SortExpression="StatusCodePrev"></asp:BoundField>
	<asp:BoundField DataField="StatusCodeDate" HeaderText="Status Code Date" SortExpression="StatusCodeDate" DataFormatString="{0:MM/dd/yy}"></asp:BoundField>

	<asp:BoundField DataField="Home Phone #" HeaderText="Phone Home" SortExpression="Home Phone #"></asp:BoundField>
	<asp:BoundField DataField="Work Phone #" HeaderText="Phone Work" SortExpression="Work Phone #"></asp:BoundField>
	<asp:BoundField DataField="PhoneCell" HeaderText="Phone Cell" SortExpression="PhoneCell"></asp:BoundField>
	<asp:BoundField DataField="PhoneOther" HeaderText="Phone Other" SortExpression="PhoneOther"></asp:BoundField>
	<asp:BoundField DataField="TeamRange" HeaderText="Team Range" SortExpression="TeamRange"></asp:BoundField>
	<asp:BoundField DataField="Open Date" HeaderText="Open Date" SortExpression="Open Date" DataFormatString="{0:MM/dd/yy}"></asp:BoundField>
</Columns>
</UI:GridViewMB>
</ContentTemplate></asp:UpdatePanel>
</div>
<table>
<tr VAlign="top">
<td rowspan="2">
<asp:UpdatePanel ID="upColl" UpdateMode="Always" runat="server"><ContentTemplate>
<UI:CollectionInfo ID="CollectionInfo" runat="server" />
</ContentTemplate></asp:UpdatePanel>
</td>
</tr>
</table>
<table>
<tr>
<td>
<ajaxtk:CollapsiblePanelExtender ID="cpPmts" runat="server"
	TargetControlID="pnlPmts"
	CollapseControlID="pnlPmtsHeader" ExpandControlID="pnlPmtsHeader"
	TextLabelID="lblPmtsLabel"
	ImageControlID="imgPmtsPanel"
	CollapsedImage="~/images/Buttons/expand.jpg" ExpandedImage="~/images/Buttons/collapse.jpg"
	Collapsed="true"	CollapsedText="" ExpandedText=""
	SuppressPostBack="false"
></ajaxtk:CollapsiblePanelExtender>
<asp:Panel ID="pnlPmtsHeader" CssClass="PanelHeaderBlue" style="width:100%" runat="server">
<table cellPadding="0" cellSpacing="0"><tr><th Width="1px"><asp:Image ID="imgPmtsPanel" runat="server" />
<td nowrap><label ID="lblPmtsLabel" runat="server">Payments</label></td></tr></table>
</asp:Panel> 
<asp:Panel ID="pnlPmts" runat="server" CssClass="PannelContent">

<asp:UpdatePanel ID="upPmts" UpdateMode="Always" runat="server"><ContentTemplate>
<UI:GridViewMB ID="grvPayments" DataSourceID="dsPmts" runat="server" CaptionAlign="Left" AutoGenerateColumns="false"
		ShowHeader="true" AllowSorting="true" AllowEdit="false" AllowPaging="true" PageSize="15" ShowDelete="false" RowStyle-HorizontalAlign="Right"
>
<Columns>
<!-- #include virtual = "/Controls/Collection/PaymentColumns.asp" -->
</Columns>
</UI:GridViewMB>
</ContentTemplate></asp:UpdatePanel>
</asp:Panel>
<ajaxtk:CollapsiblePanelExtender runat="server" ID="cpComm"
	TargetControlID="pnlComm"
	CollapseControlID="pnlCommHeader" ExpandControlID="pnlCommHeader"
	TextLabelID="lblCommLabel"
	ImageControlID="imgCommPanel"
	CollapsedImage="~/images/Buttons/expand.jpg" ExpandedImage="~/images/Buttons/collapse.jpg"
	Collapsed="true"	CollapsedText="" ExpandedText=""
	SuppressPostBack="false"
></ajaxtk:CollapsiblePanelExtender>
<asp:Panel ID="pnlCommHeader" CssClass="PanelHeaderBlue" style="width:100%" runat="server">
<table cellPadding="0" cellSpacing="0"><tr>
<th Width="1px"><asp:Image ID="imgCommPanel" ImageUrl="~/images/Buttons/expand.jpg" runat="server" />
<td nowrap><label ID="lblCommLabel" runat="server">Comments</label></td>
</tr></table>
</asp:Panel> 
<asp:Panel ID="pnlComm" runat="server" CssClass="PannelContent">
<asp:UpdatePanel ID="upComm" UpdateMode="Always" runat="server"><ContentTemplate>
<UI:GridViewMB ID="grvComments" DataSourceID="dsComments" runat="server" CaptionAlign="Left" AutoGenerateColumns="false"
		ShowHeader="true" AllowSorting="true" AllowEdit="false" AllowPaging="true" ShowDelete="false" RowStyle-HorizontalAlign="Right" PageSize="10"
>
<Columns>
<asp:BoundField DataField="Date" DataFormatString="{0:MM/dd/yyyy}" HtmlEncode="false" HeaderText="Date" SortExpression="Date"></asp:BoundField>
<asp:BoundField DataField="Remark" HeaderText="Remark" DataFormatString="<pre style='font-size:125%'>{0}</pre>" HtmlEncode="false" SortExpression="Remark"></asp:BoundField>
<asp:BoundField DataField="Agent" HeaderText="Agent" DataFormatString="<pre style='font-size:125%'>{0}</pre>" HtmlEncode="false" SortExpression="Agent"></asp:BoundField>
<asp:BoundField DataField="Due Date" DataFormatString="{0:MM/dd/yyyy}" HtmlEncode="false" HeaderText="Due Date" SortExpression="Due Date"></asp:BoundField>
</Columns>
</UI:GridViewMB>
</ContentTemplate></asp:UpdatePanel>
</asp:Panel>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
<UI:Notes ID="Notes" runat="server" />
<asp:HiddenField id="hdnFilterName" runat="server" />
<asp:HiddenField id="hdnFilterUser" runat="server" />

<UI:PaymentsMB ID="PmtsMB" runat="server" />

<DS:ProfileFiltersDataSource ID="dsFilters" runat="server">
<SelectParameters>
<asp:ControlParameter PropertyName="FilterUser" Name="UserName" Type="String" DefaultValue="" />
</SelectParameters>
</DS:ProfileFiltersDataSource>
<DS:USIXPaymentsDataSource ID="dsPmts" runat="server">
<SelectParameters>
<asp:ControlParameter ControlID="dsPmts" PropertyName="Page.UsixID" Name="UsixID" Type="String" />
<asp:ControlParameter ControlID="dsPmts" PropertyName="Page.CompanyID" Name="CompanyID" Type="Int32" />
</SelectParameters>
</DS:USIXPaymentsDataSource>

<DS:USIXCommentsDataSource ID="dsComments" runat="server">
<SelectParameters>
<asp:ControlParameter ControlID="dsPmts" PropertyName="Page.UsixID" Name="UsixID" Type="String" />
<asp:ControlParameter ControlID="dsPmts" PropertyName="Page.CompanyID" Name="CompanyID" Type="Int32" />
</SelectParameters>
</DS:USIXCommentsDataSource>
<DS:UsersDataSource ID="dsUsers" OrderBys="Nick" ShowProfiles="true" runat="server" />
<cool:tip delay="700" avoidMouse="true" duration="60"></cool:tip>
<pre id="pre" runat="server"></pre>
<input id="btnProfiler" onclick="showProfileManager()" value="Profiler" type="button" runat="server" />
<script>
pageLoads.push(GVX_InitHeader);
pageLoadsAsync.push(GVX_InitHeader);
function InitHeader(){
	var inputs = divGrid.all.tags("INPUT");
	for( var i=0 ; i < inputs.length; i++ ){
		if( inputs[i].type != "text" )continue;
//		inputs[i].onkeypress = null;
//		inputs[i].delay = 700;
//		inputs[i].coolTip = inputs[i].title.replace(/\r\n/g,"<br>");
//		inputs[i].title = "";
		inputs[i].onfocus = function(){
			event.srcElement.style.position = "relative";
			event.srcElement.style.borderColor = "maroon";
			event.srcElement.style.zIndex=1000;
			event.srcElement.style.backgroundColor="white";
			//showTip(this);
		};
		inputs[i].onblur = function(){
			event.srcElement.style.position = "";
			event.srcElement.style.borderColor = "";
			event.srcElement.style.zIndex=null;
			event.srcElement.style.backgroundColor="";
		};
	}
}
function showTip(el){
//el.coolTip = "Dimok";
	var tip = ((el.coolTip||"").match(/.+?<br>(.+)/)||new Array("",""))[1];
	el.coolTip = (el.value.fontcolor("navy").bold() + "<br>" + tip.replace(/(XXX|YYY|ZZZ)/g,"$1".fontcolor("#B80000").bold()));//.fontsize(3);
}
function showProfileManager(){
	showModelessDialog("/Manager/Admin/ProfilesManager.aspx",null,"resizable=1");
}
function importFromUSIX(el){
	event.cancelBubble = true;
	if( confirm("Import this loan from USIX?") )
		el.parentElement.all.tags("A")[0].click();
}
</script>
<?XML:NAMESPACE PREFIX="COOL" />
